package org.xfy.sys.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import org.xfy.base.service.impl.BaseServiceImpl;
import org.xfy.base.util.PageList;
import org.xfy.sys.domain.DictionaryDetail;
import org.xfy.sys.mapper.DictionaryDetailMapper;
import org.xfy.sys.query.DictionaryDetailQuery;
import org.xfy.sys.service.IDictionaryDetailService;

import java.util.List;

@Service
public class DictionaryDetailServiceImpl extends BaseServiceImpl<DictionaryDetail> implements IDictionaryDetailService {
    @Autowired
    private DictionaryDetailMapper dictionaryDetailMapper;
    @Override
    public List<DictionaryDetail> findDetailsByTypeid(Long id) {
        return dictionaryDetailMapper.findDetailsByTypeid(id);
    }

    @Override
    public PageList<DictionaryDetail> queryPage(DictionaryDetailQuery query) {
        //先查询总数量
        Long count = dictionaryDetailMapper.queryCount(query);
        if(count < 1){//在没有数据的情况下可以提高查询效率
            return new PageList<DictionaryDetail>();
        }
        //再查询当前页的分页数据
        List<DictionaryDetail> list = dictionaryDetailMapper.queryPage(query);
        PageList<DictionaryDetail> pageList = new PageList<>();
        pageList.setData(list);
        pageList.setTotals(count);
        //返回查询结果
        return pageList;
    }
}
